<!-- 我的弹窗 -->

<template>
  <WebModal word="仓库" small>
    <WebForm>
      <FormInput label="仓库编号" bind="warehouseCode" required disabled />

      <FormInput label="仓库名称" bind="warehouseName" :max="10" required />

      <FormTree
        :label="`所属${CORE.MAP.ORGAN}`"
        bind="organizationId, organizationName"
        :dict="CORE.ORGAN.DICT"
        allName
        required
      />
      <FormInput v-if="isShow" label="负责人" bind="principalName" />
      <FormSelect
        v-else-if="user_readySelect"
        label="负责人"
        bind="principalId, principalName"
        :dict="user_selectDict"
        required
      />

      <FormTextarea label="详细地址" bind="address" :rows="2" :max="50" />

      <FormTextarea label="备注信息" bind="description" :rows="2" :max="20" />
    </WebForm>
  </WebModal>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyModal',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb(), CORE.mixSelect('user', 'user_')],

  /**
   * 监听属性 (深度 deep 首次 immediate)
   */
  watch: {
    /**
     * 监听组织 ID
     */
    'one.organizationId': {
      immediate: true,
      handler(organId) {
        this.changeOrgan(organId)
      },
    },
  },

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 切换组织
     */
    changeOrgan(organId) {
      const { user_selectParam, user_setSelect, user_startSelect } = this
      user_selectParam.organId = organId ? [organId] : []
      user_setSelect()
      user_startSelect()
    },
  },
}
</script>
